package com.yanqu.road.dao.impl.servercenter;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.servercenter.PackageUpdateInfo;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * 整包版本信息
 */
public class PackageUpdateDaoImpl extends TempDao {

	public List<PackageUpdateInfo> getPackageUpdateInfoList() {
		ResultSet rs = null;
		CallableStatement call = null;
		String sql = "select * from t_s_package_update where isDelete=0";
		List<PackageUpdateInfo> dataList = new ArrayList<>();
		try {
			getDb().setConnName(DbNameStrategy.getServerDb());
			call = getDb().getConnection().prepareCall(sql);
			rs = call.executeQuery();
			while (rs.next()) {
				PackageUpdateInfo data = new PackageUpdateInfo();
				data.setPackageMark(rs.getString("packageMark"));
				data.setPackageMinVersion(rs.getString("packageMinVersion"));
				data.setPackageMaxVersion(rs.getString("packageMaxVersion"));
				data.setUpdateScopeStr(rs.getString("updateScope"));
				data.setUpdateLevel(rs.getInt("updateLevel"));
				data.setUpdateMethod(rs.getInt("updateMethod"));
				data.setDownloadUrl(rs.getString("downloadUrl"));
				dataList.add(data);
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			getDb().closeConnection(call, rs);
		}
		return dataList;
	}
}
